unit fBaseManage;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, VirtualTrees, dxBar, cxClasses, StdCtrls,
  uDAScriptingProvider, uDADataTable, uDAMemDataTable, fClientDataModule, fEmbedTlb,uPublic,
  Menus;

type
  TfmBaseManage = class(TForm)
    pnlLeft: TPanel;
    vstItems: TVirtualStringTree;
    pnlRight: TPanel;
    lblDetailTitle: TLabel;
    tblBase: TDAMemDataTable;
    Splitter1: TSplitter;
    PopupMenu1: TPopupMenu;
    asdfasdf1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  protected
    FSql: string;
    FIdField: string;
    FEmbedForm: TfmEmbedTlb;
  public
    { Public declarations }
    procedure Initialize; virtual; abstract;
    procedure InitDataSets;
    procedure CloseDataSets;
    procedure ShowEmbedForm(AFormClass: TFormClass; AOwner: TComponent; AAccessType: TFormAccessType; AId: TGuid);
    
  end;

var
  fmBaseManage: TfmBaseManage;

implementation

uses
  fClientForm;

{$R *.dfm}

procedure TfmBaseManage.ShowEmbedForm(AFormClass: TFormClass; AOwner: TComponent;AAccessType: TFormAccessType;Aid: TGuid);
begin
  LockWindowUpdate(Handle);
  if FEmbedForm <> nil then
    FEmbedForm.Close;
  TForm(FEmbedForm) := AFormClass.Create(self);
  FEmbedForm.Align := alClient;
  FEmbedForm.BorderStyle := bsNone;
  FEmbedForm.Parent := TWinControl(AOwner);
  FEmbedForm.AccessType := AAccessType;
  FEmbedForm.Initialize(AId);
  FEmbedForm.Visible := True;
  LockWindowUpdate(0);  
end;

procedure TfmBaseManage.CloseDataSets;
begin
  tblBase.Close;
end;

procedure TfmBaseManage.InitDataSets;
begin
  if tblBase.Active then
    tblBase.Close;
  ClientDataModule.rdaDynamic.GetDataCall.ParamByName('aSQLText').AsString := FSql;
  tblBase.MaxRecords := -1;
  ClientDataModule.rdaDynamic.Fill([tblBase], true, true);
end;

procedure TfmBaseManage.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfmBaseManage.FormCreate(Sender: TObject);
begin
  ClientForm.SetFormName(self.Caption);
end;

procedure TfmBaseManage.FormDestroy(Sender: TObject);
begin
  ClientForm.DelFormName(self.Caption);
end;

end.
